<?php

use yii\db\Migration;

class m000000_000001_create_system extends Migration
{
    public function safeUp()
    {
        $this->createTable('{{%system}}', [
            'id' => $this->integer(),
            'category' => $this->string(32)->notNull()->comment('类别'),
            'show_name' => $this->string(32)->notNull()->comment('说明'),
            'name' => $this->string(128)->notNull()->comment('名称'),
            'type' => $this->string(512)->notNull()->comment('类型'),
            'value' => $this->text()->comment('值'),
        ]);
        $this->batchInsert('{{%system}}', ['id', 'category', 'show_name', 'name', 'type', 'value'], [
            [1, '系统设置', '系统版本', 'system_version', json_encode(['type' => 'text', 'disabled' => true]), '1.0.0'],
            [1001, '网站设置', '商城名称', 'site_name', json_encode(['type' => 'text']), ''],
            [1002, '网站设置', '商城LOGO', 'site_logo', json_encode(['type' => 'file']), ''],
            [1003, '网站设置', '首页标题', 'site_index_title', json_encode(['type' => 'text']), ''],
            [1004, '网站设置', '首页描述', 'site_index_desc', json_encode(['type' => 'text']), ''],
            [1005, '网站设置', '首页关键字', 'site_index_keywords', json_encode(['type' => 'text']), ''],
            [1006, '网站设置', '许可证', 'site_license', json_encode(['type' => 'text']), ''],
            [1007, '网站设置', '联系客服页面', 'site_contact', json_encode(['type' => 'richtext']), ''],
            [1008, '网站设置', '流量统计代码', 'site_statistics', json_encode(['type' => 'plaintext']), ''],
            [1101, '系统设置', 'ActiveMQ地址', 'mq_url', json_encode(['type' => 'text']), ''],
        ]);
    }

    public function down()
    {
        $this->dropTable('{{%system}}');
    }
}
